#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/5/5 下午11:48
# @Author  : wanyongtao
# @Site    : 
# @File    : ApiHandler.py
# @Software: PyCharm

import logging
import json
import constants

from handlers.BaseHandler import BaseHandler
from utils.response_code import RET

class ApiTemplateHandler(BaseHandler):

    def get(self):
        '''
        get方法例子
        :return:
        '''
        id = self.get_argument("id")
        if not id:
            return self.write({"errcode": RET.NODATA, "errmsg": "id为空"})
        data = {'id':id}
        self.write(dict(errcode=RET.OK, errmsg="OK", data=data))

    def post(self):
        '''
        post 提交json数据
        :return:
        '''
        id = self.json_args.get("id")
        if not id:
            return self.write({"errcode": RET.NODATA, "errmsg": "id为空"})

        data = {'id': id}
        self.write(dict(errcode=RET.OK, errmsg="OK", data=data))